'''
@Author ：czh
@Date ：2022/3/11 0011 11:03 
@remark：
'''

import json
import re
from jsonpath_rw import parse  # 第三方插件，需要pip install ,作用json数据提取

import requests

#拼接url
from requests import cookies
headers = {
    'Content-Type':'application/json; charset=UTF-8',
    'Host':'test.369zhan.com',
    'Accept': 'application/json, text/javascript, */*; q=0.01',
    }
host =r'http://test.369zhan.com/portal/rest/login'
data={"mobilePhone":"930419","password":"1"}
#初始化url请求对象
r = requests.post(url=host,data=json.dumps(data),headers=headers)
#获取url请求对象中的有用信息，如token、cookies
# token = r.cookies.items()[0][1]
cookies = r.cookies
token=r.headers.get("X-Auth-Token")
# head=r.headers
#以下为测试，所获取的token及cookie的格式
# print(type(token))   #获取token的类型
# print(token)         #打印token
# print(cookies)       #打印cookies
# print(r.json())         #打印URL
print(r.headers)         #打印URL
print(token)

data={"testfan-token":"${neeo_001>response_json>data}$","userName":"${neeo_001>request_headers>userName}$"}
token1=data.get("testfan-token")
print(token1)


